//Class that maps a word to a set of occurances
#ifndef KEYWORDINDEX_H
#define KEYWORDINDEX_H

#include "BST.h"
#include "LinkedList.h"
#include "OccurrenceSet.h"
#include <string>
#include <iostream>

//Wrapper class for the map. Holds the Key word and set of Occurances
class MapNode{
	friend class KeyWordIndex;

public:
	MapNode(string &key){
		word = new string(key);
	}

	MapNode(const MapNode &other):set(other.set){
		word = new string(*(other.word));
		
	}

	~MapNode(){
		delete word;
	}

	void add(Page &site){
		set.add(site);
	}

	int compare(MapNode &other){
		return word->compare(*(other.word));
	}

	string * getWord(){
		return word;
	}

	friend ostream &operator<<(ostream &stream, MapNode *o);
	friend ostream &operator<<(ostream &stream, MapNode o);

	private:
		string *word;
		OccurrenceSet set;



};


class KeyWordIndex{

	private:
		BST<MapNode> tree;
		//BST that holds data structure

	public:
		KeyWordIndex();
		void add(string &word, Page &site);
		//Add methood that accepts the key word and URL link associated with it

		OccurrenceSet* getSet(string &word);
		//Returns the set of occurances for a given word
		LinkedList<string>* getWords();
		//Returns a linked list of words which can be used for accsessing the values in the KeyWordIndex

}; 

#endif
